package com.pilot.game.service;

import com.pilot.game.domain.CyclePlan;
import com.pilot.game.repository.CyclePlanRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * Service Implementation for managing CyclePlan.
 */
@Service
@Transactional
public class CyclePlanService {

    private final Logger log = LoggerFactory.getLogger(CyclePlanService.class);

    private final CyclePlanRepository cyclePlanRepository;

    public CyclePlanService(CyclePlanRepository cyclePlanRepository) {
        this.cyclePlanRepository = cyclePlanRepository;
    }

    /**
     * Save a cyclePlan.
     *
     * @param cyclePlan the entity to save
     * @return the persisted entity
     */
    public CyclePlan save(CyclePlan cyclePlan) {
        log.debug("Request to save CyclePlan : {}", cyclePlan);
        return cyclePlanRepository.save(cyclePlan);
    }

    /**
     *  Get all the cyclePlans.
     *
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Transactional(readOnly = true)
    public Page<CyclePlan> findAll(Pageable pageable) {
        log.debug("Request to get all CyclePlans");
        return cyclePlanRepository.findAll(pageable);
    }

    /**
     *  Get one cyclePlan by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Transactional(readOnly = true)
    public CyclePlan findOne(Long id) {
        log.debug("Request to get CyclePlan : {}", id);
        return cyclePlanRepository.findOne(id);
    }

    /**
     *  Delete the  cyclePlan by id.
     *
     *  @param id the id of the entity
     */
    public void delete(Long id) {
        log.debug("Request to delete CyclePlan : {}", id);
        cyclePlanRepository.delete(id);
    }

    @Transactional(readOnly = true)
    public Page<CyclePlan> findAllWithStatus(int kindId, int status, Pageable pageable) {
        log.debug("Request to get all CyclePlans:kindId:{},status:{}", kindId, status);
        return cyclePlanRepository.findAllWithStatus(kindId, status, pageable);
    }
}
